home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
- Subject: Re: Seek unix2dos.c OR help with tr
- Date: 11 Mar 96 11:59:37 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.826545577@rscernix>
- References: <4i0946$7io@nuke.csu.net>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <4i0946$7io@nuke.csu.net> mclean@futon.SFSU.EDU (Emmett Mclean) writes:
-
- >Does anyone have the source to a program
- >converting a unix file into dos format?
- >That is, each decimal 10 char is replaced
- >with a series of a 10 and 13.
-
- Thinking and programming in terms of magic numbers is a bad idea.
- Someone who is less familiar with the ASCII character set won't be able
- to make any sense out of your code. A program which will replace '\n'
- by the '\r' '\n' sequence will be considerably more readable, even if
- portability is not a concern (both DOS and Unix use the ASCII character
- set).
-
- >The equivalent syntax to tr would be fine
- >as well.
-
- As far as I know, tr can replace characters, can drop characters but
- cannot insert characters.
-
- >I will be using it to download zipped binaries
- >files from a unix box.
-
- Then, you DON'T want to touch any character in the file. The conversion
- makes sense only for TEXT files and is guarantee to turn a binary file
- into complete garbage.
-
- >Ah, writing the program is a bit trickier
- >than the little program below since the
- >program exits prematurely because getchar reads
- >EOF from its input - before getting to
- >the real EOF.
-
- This is because your implementation is brain dead and you didn't bother
- to read the FAQ.
-
- OTOH, if the file contains a character which compares equal to EOF,
- that file is _probably_ not a text file and it makes little sense to
- pass it through your filter.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-